﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using DevExpress.Xpf.Core;
using UIT.ScrumTool.Client.Controller;
using UIT.ScrumTool.Client.ControlService;
using UIT.ScrumTool.Client.Utilities.Team;
using UIT.ScrumTool.Client.View.Project;


namespace UIT.ScrumTool.Client.View.Team
{
    /// <summary>
    /// Interaction logic for dxwTeamInfo.xaml
    /// </summary>
    public partial class dxwTeamInfo : DXWindow
    {
        public dxwTeamInfo()
        {
            InitializeComponent();
        }

        // Add a New Team
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(txtTeamName.Text))
            {
                lbWarning.Visibility = System.Windows.Visibility.Visible;
                this.txtTeamName.Focus();
            }
            else
            {
                TeamDto teamDto = new TeamDto();
                teamDto.Name = txtTeamName.Text;
                teamDto.Description = tbDescription.Text;
                teamDto.ProjectId = uctrlProject.projectId;
                int teamId = TeamCtrl.TeamInsert(teamDto);

                TeamInfo teamInfo = new TeamInfo();
                teamInfo.TeamId = teamId;
                teamInfo.TeamName = teamDto.Name;
                teamInfo.Description = teamDto.Description;
                teamInfo.LstMemberTeam = null;


                if (uctrlProject.lstTeam == null)
                {
                    uctrlProject.lstTeam = new List<TeamInfo>();
                }
                uctrlProject.lstTeam.Add(teamInfo);
                this.Close();

                uctrlProject._uctrlProject.RefreshListViewTeam();
            }
        }
    }
}
